package cn.lili.modules.system.entity.dto;

import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.system.entity.dos.LiAuthLog;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.io.Serial;

/**
 * 日志分页查询
 */

@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuthSearchParams extends PageVO {
    @Serial
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "授权Appid")
    private String authAppid;

    @ApiModelProperty(value = "状态")
    private String status;

    @ApiModelProperty(value = "状态")
    private String type;

    /**
     * 构建查询对象
     * @return 查询条件
     * */
    public LambdaQueryWrapper<LiAuthLog> queryWrapper(){
        return new LambdaQueryWrapper<LiAuthLog>()
                .eq(StringUtils.isNotEmpty(status),LiAuthLog::getStatus,status)
                .eq(StringUtils.isNotEmpty(authAppid),LiAuthLog::getAuthAppid,authAppid)
                .like(StringUtils.isNotEmpty(type),LiAuthLog::getType, type)
                .orderByDesc(LiAuthLog::getCreateTime);
    }
}
